import React from "react";

export default class IfDemo extends React.Component{
    constructor(){
        super()
        this.state={
            isLogin:false
        }
    }

    render(){
        let showView=this.state.isLogin?<div>已登录</div>:<div>未登录</div>
        return (
            <div>
                <h1>条件渲染</h1>
                {showView}
                <button onClick={this.changLogin}>切换</button>
            </div>
        )
    }

    changLogin=()=>{
        this.setState({
            isLogin:!this.state.isLogin
        })
    }
}